-
Notifications
You must be signed in to change notification settings - Fork 209
fix: correctly generate anyOf on unions with string and boolean constant #2208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
} | ||
] | ||
}, | ||
"var8": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if we can use enum
and type[]
in the same type. Especially the combination of boolean, string, and true
.
I'd bet that even if allowed, this would break in a lot of community parsers. Could we make this be a anyOf boolean const true
and string enum s
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn’t this the analog case for var4 and var6, apart from using a number
instead of boolean
?
regarding whether it is allowed, at least for type
and enum
I don’t see a indication that they are exclusive (https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.1.1). it feels a bit redundant to specify both, as enum
implicitly specifies type
b6dcdaa
to
56bdaf7
Compare
@domoritz any objection in merging this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code lgtm
as far as I understood while debugging through the test code,StringType
is used forstring
whileLiteralType
is used for a string constant like"s"
, thusStringType
cannot be part of a literal union.noticed that there is some magic regarding
string
which is hard to incorporate outside ofLiterallUnionTypeFormatter
. but it appears to me that aStringType
could get discarded when it is not marked as preserve literalscloses #2207